package kr.saeildamil.androidstudy_second24;

import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.View;

public class AnimView extends View {
	Ball mBall;
	Paint mPaint;

	
	public AnimView(Context context) {
		super(context);
		mBall=new Ball();
		mBall.setX(100);
		mBall.setY(50);
		mBall.setRad(20);
		
		mPaint=new Paint();
		mPaint.setColor(mBall.getColor());
	}
	
	
	public void startAnim(int id){
		mBall.setX(100);
		mBall.setY(50);
		mBall.setRad(20);
		
	
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		canvas.drawCircle(mBall.getX(), mBall.getY(), mBall.getRad(), mPaint);
	}

	public void startAnim() {
		ObjectAnimator anim=ObjectAnimator.ofInt(mBall, "x", 100, 400);
		anim.setDuration(2000);
		anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
			
			@Override
			public void onAnimationUpdate(ValueAnimator animation) {
				invalidate();
			}
		});
		anim.start();
	}
}
